package lormi.meipin.controller.api;

import lormi.meipin.common.Result;
import lormi.meipin.controller.BaseController;
import lormi.meipin.exception.LMException;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;


/**
 * 分享管理
 * */
@RestController
@RequestMapping(value="v2/share",method=RequestMethod.POST,produces = "application/json; charset=utf-8")
public class ShareController extends BaseController{

	/**
	 * 添加分享
	 * @Param userid 用户ID
	 * @Param usertype 用户类型
	 * @Param sharetype 分享类型
	 * @Param viewnum 阅读次数
	 * 
	 * */
	@RequestMapping("add")
	@Valid
	public String add(@NotNull(message="100033") @RequestParam(value="userid") Integer userid,
			@NotNull(message="100033") @RequestParam(value="sharetype") Integer sharetype
			,@NotNull(message="100033") @RequestParam(value="viewnum") Integer viewnum) throws LMException{
		shareService.addShare(userid, sharetype, viewnum);
		
		return Result.success();
	}
	
	/**
	 * 获取分享文字
	 */
	@RequestMapping("text")
	public String shareText() throws LMException {
		return Result.success(systemInfoService.getShareText());
	}
	
	
	
}
